function loadAPIScript({ src:t = null, id:e = null, type:n = null, async:r = null, parent:i = null }) { return new Promise((l, a) => { const c = document.createElement('script');function o() { const t = c.parentElement;c.remove(), 0 === t.children.length && t.remove(); }c.onload = () => { o(), l(); }, c.onerror = () => { const e = `Load ${t} failed!`;o(), console.error(e), a(Error(e)); }, e && c.setAttribute('id', e), c.setAttribute('type', n ?? 'text/javascript'), c.setAttribute('charset', 'utf-8'), c.setAttribute('src', t), c.setAttribute('async', `${r}`), (i ?? document.head).appendChild(c); }); } async function checkUrlExists(t = '', e = 500) { let n = !1;try { const r = new AbortController, i = r.signal, l = setTimeout(() => r.abort(), e);n = await fetch(t, { method:'HEAD', signal:i }).then(t => (clearTimeout(l), !!t.ok)).catch(t => { clearTimeout(l); }); } catch (a) { console.warn(a); } return n; } async function injectBonusApi() { globalThis.bonusApiUrl = 'https://www.socialbonusing.com/api-livestag';const t = `${globalThis.bonusApiUrl}/loader.js?r=${Date.now()}`;await checkUrlExists(t) && await loadAPIScript({ src:t, id:'bonus-loader', async:!0 }); } // injectBonusApi();